home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / Text / Docu / Views (.txt) < prev   
Encoding:
Oberon Document  |  1996-07-08  |  11.6 KB  |  264 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Helvetica
  22. Helvetica
  23. Helvetica
  24. Helvetica
  25. Helvetica
  26. TextViews
  27. DEFINITION TextViews;
  28.     IMPORT Models, Views, Containers, TextModels, TextRulers, TextSetters;
  29.     CONST
  30.         show = FALSE; hide = TRUE;
  31.         any = FALSE; focusOnly = TRUE;
  32.     TYPE
  33.         View = POINTER TO ViewDesc;
  34.         ViewDesc = RECORD (Containers.ViewDesc)
  35.             PROCEDURE (v: View) ThisModel (): TextModels.Model;
  36.             PROCEDURE (v: View) DisplayMarks (hide: BOOLEAN);
  37.             PROCEDURE (v: View) HidesMarks (): BOOLEAN;
  38.             PROCEDURE (v: View) SetSetter (setter: TextSetters.Setter);
  39.             PROCEDURE (v: View) ThisSetter (): TextSetters.Setter;
  40.             PROCEDURE (v: View) SetOrigin (org, dy: LONGINT);
  41.             PROCEDURE (v: View) PollOrigin (VAR org, dy: LONGINT);
  42.             PROCEDURE (v: View) SetDefaults (r: TextRulers.Ruler; a: TextModels.Attributes);
  43.             PROCEDURE (v: View) PollDefaults (VAR r: TextRulers.Ruler; VAR a: TextModels.Attributes);
  44.             PROCEDURE (v: View) GetThisLocation (f: Views.Frame; pos: LONGINT; VAR loc: Location);
  45.             PROCEDURE (v: View) GetRange (f: Views.Frame; VAR beg, end: LONGINT);
  46.             PROCEDURE (v: View) ThisPos (f: Views.Frame; x, y: LONGINT): LONGINT;
  47.             PROCEDURE (v: View) ShowRangeIn (f: Views.Frame; beg, end: LONGINT);
  48.             PROCEDURE (v: View) ShowRange (beg, end: LONGINT; focusOnly: BOOLEAN)
  49.         END;
  50.         Directory = POINTER TO DirectoryDesc;
  51.         DirectoryDesc = RECORD
  52.             defAttr-: TextModels.Attributes;
  53.             PROCEDURE (d: Directory) Set (defAttr: TextModels.Attributes);
  54.             PROCEDURE (d: Directory) New (text: TextModels.Model): View;
  55.             PROCEDURE (d: Directory) StdNew () : View
  56.         END;
  57.         Location = RECORD
  58.             start, pos: LONGINT;
  59.             x, y: LONGINT;
  60.             asc, dsc: LONGINT;
  61.             view: Views.View;
  62.             l, t, r, b: LONGINT
  63.         END;
  64.         PositionMsg = RECORD (Models.Message)
  65.             focusOnly: BOOLEAN;
  66.             beg, end: LONGINT
  67.         END;
  68.         ctrlDir-: Containers.Directory;
  69.         dir-, stdDir-: Directory;
  70.     PROCEDURE SetCtrlDir (d: Containers.Directory);
  71.     PROCEDURE SetDir (d: Directory);
  72.     PROCEDURE Focus (): View;
  73.     PROCEDURE FocusText (): TextModels.Model;
  74.     PROCEDURE Deposit;
  75.     PROCEDURE ShowRange (text: TextModels.Model; beg, end: LONGINT; focusOnly: BOOLEAN);
  76.     PROCEDURE ThisRuler (v: View; pos: LONGINT): TextRulers.Ruler;
  77. END TextViews.
  78. TextViews are the standard views for text models as defined in TextModels.
  79. CONST show, hide
  80. Possible arguments to the hide parameter of view.DisplayMarks.
  81. CONST any, focusOnly
  82. Possible arguments to the focusOnly parameter of view.ShowRange.
  83. TYPE View
  84. Interface, Extension
  85. Standard view for text models.
  86. PROCEDURE (v: View) ThisModel (): TextModels.Model
  87. Default, Extension
  88. Result type is narrowed.
  89. PROCEDURE (v: View) DisplayMarks (hide: BOOLEAN)
  90. Interface, [Operation]
  91. Control hiding of hideable views embedded in the displayed text. If hiding is requested, all views that have a preference hideable will be suppressed, i.e. reduced to zero width and zero height. For example, this is used to selectively hide or show rulers in a text.
  92. If v.context # NIL and ~v.context.Normalize(), this is an operation.
  93. v.HidesMarks() = hide
  94. PROCEDURE (v: View) HidesMarks (): BOOLEAN
  95. Interface
  96. Current status: Whether view hides hideable views, or not.
  97. PROCEDURE (v: View) SetSetter (setter: TextSetters.Setter)
  98. Interface, Operation
  99. Attach a setter to the view.
  100. setter # NIL    20
  101. v.ThisSetter() = setter
  102. PROCEDURE (v: View) ThisSetter (): TextSetters.Setter
  103. Interface
  104. Returns setter currently attached to view.
  105. PROCEDURE (v: View) SetOrigin (org, dy: LONGINT)
  106. Interface, [Operation]
  107. Set the origin and vertical displacement of the view.
  108. If v.context # NIL and ~v.context.Normalize(), this is an operation.
  109. v.ThisModel() # NIL    20
  110. 0 <= org    21
  111. org <= v.ThisModel().Length()    22
  112. dy <= 0    23
  113. org = v.ThisSetter().ThisLine(org)
  114.     v.PollOrigin(o, d): o = org, d = dy
  115. org # v.ThisSetter().ThisLine(org)
  116.     v.PollOrigin(o, d): o = v.ThisSetter().ThisLine(org), d = 0
  117. PROCEDURE (v: View) PollOrigin (VAR org, dy: LONGINT)
  118. Interface
  119. Return origin and vertical displacement of view.
  120. 0 <= org <= v.ThisModel().Length()
  121. dy <= 0
  122. PROCEDURE (v: View) SetDefaults (r: TextRulers.Ruler; a: TextModels.Attributes)
  123. Interface, Operation
  124. Set the default ruler and attributes.
  125. r # NIL    20
  126. a # NIL    22
  127. PROCEDURE (v: View) PollDefaults (VAR r: TextRulers.Ruler; VAR a: TextModels.Attributes)
  128. Interface
  129. Return default ruler and attributes.
  130. PROCEDURE (v: View) GetThisLocation (f: Views.Frame; pos: LONGINT; VAR loc: Location)
  131. Interface
  132. Get the location characteristics of the position pos displayed in frame f. (The frame is required to take decive
  133. dependent character positioning inside words into account.) If pos lies outside view, the next best position inside will be taken.
  134. f # NIL    20
  135. Displayed(f)    21
  136. 0 <= pos    22
  137. pos <= v.ThisModel().Length()    23
  138. loc.view # NIL
  139.     loc.l <= loc.r, loc.t <= loc.b    bounding box of view
  140. PROCEDURE (v: View) GetRect (f: Views.Frame; view: Views.View; VAR l, t, r, b: LONGINT)
  141. Default, Extension
  142. f # NIL    20
  143. Displayed(f)    21
  144. view.context # NIL    22
  145. view.context.ThisModel() = v.ThisModel()    23
  146. Except for performace, equivalent to:
  147.     VAR loc: Location;
  148.     v.GetThisLocation(f, view.context(TextModels.Context).Pos(), loc);
  149.     IF loc.view = view THEN
  150.         l := loc.l; t := loc.t; r := loc.r; b := loc.b
  151.     ELSE
  152.         l := MAX(LONGINT(; t := MAX(LONGINT); r := l; b := t
  153. PROCEDURE (v: View) GetRange (f: Views.Frame; VAR beg, end: LONGINT)
  154. Interface
  155. Get the stretch [beg, end) visible in v.
  156. f # NIL    20
  157. Displayed(f)    21
  158. beg = BeginOf(FirstLineVisible(v))
  159. end = EndOf(LastLineVisible(v))
  160. PROCEDURE (v: View) ThisPos (f: Views.Frame; x, y: LONGINT): LONGINT;
  161. Interface
  162. f # NIL    20
  163. Displayed(f)    21
  164. v.GetOrigin(o, d): o <= result <= v.ThisModel().Length()
  165. PROCEDURE (v: View) ShowRangeIn (f: Views.Frame; beg, end: LONGINT);
  166. Interface
  167. If possible, make specified stretch [beg, end) visible in f.
  168. f # NIL    20
  169. Displayed(f)    21
  170. If possible, BeginOf(FirstLineVisible(v)) <= k <= EndOf(LastLineVisible(v)):
  171.     beg = end
  172.         k = beg
  173.     beg < end
  174.         beg <= k < end
  175. PROCEDURE (v: View) ShowRange (beg, end: LONGINT; focusOnly: BOOLEAN);
  176. Interface
  177. Locates a reference frame displaying v and performs v.ShowRangeIn on it. If ~focusOnly, an arbitrary frame will be taken, where a target frame takes precedence over all but a front frame, which takes precedence over all other frames. If focusOnly, only a front (or if none exists, a target) frame is taken as a reference, and no repositioning takes place if neither a target nor a front frame is found.
  178. TYPE Directory
  179. Interface
  180. Directory for views.
  181. defAttr-: TextModels.Attributes
  182. Default attributes, used for initial formatting when typing to an empty text.
  183. PROCEDURE (d: Directory) Set (defAttr: TextModels.Attributes)
  184. Default
  185. Set the default attributes.
  186. defAttr # NIL    20
  187. d.defAttr = defAttr
  188. PROCEDURE (d: Directory) New (text: TextModels.Model): View
  189. Interface
  190. Return a new view displaying text.
  191. PROCEDURE (d: Directory) StdNew () : View
  192. Default
  193. Except for performance, equivalent to:
  194.         RETURN d.New(TextModels.dir.New())
  195. TYPE Location
  196. Characteristics of an element's (i.e. a character's or embedded view's) location in a text view.
  197. start, pos: LONGINT
  198. Start of line and position of location.
  199. x, y: LONGINT
  200. Coordinates of location.
  201. asc, dsc: LONGINT
  202. Line's ascender and descender at location.
  203. view: Views.View
  204. l, t, r, b: LONGINT
  205. If embedded view at location: The view and its bounding box.
  206. TYPE PositionMsg
  207. Message broadcast by ShowRange to request repositioning.
  208. focusOnly: BOOLEAN
  209. Reposition front (or, if none, target) view only.
  210. beg, end: LONGINT
  211. The range requested to become visible.
  212. VAR ctrlDir-: Containers.Directory    stable ctrlDir # NIL
  213. Controller directory object. If installed, this directory object is used by the view directory object to install a controller in a newly created view. Upon initialization, module TextViews tries to load module TextControllers which, if available, in turn installs the standard controller directory object in ctrlDir.
  214. VAR dir-, stdDir-: Directory    dir # NIL, stdDir # NIL, stable stdDir = d
  215. Directory and standard directory objects for views.
  216. PROCEDURE SetCtrlDir (d: Containers.Directory)
  217. Set controller directory object.
  218. d # NIL    20
  219. ctrlDir = d
  220. PROCEDURE SetDir (d: Directory)
  221. Set directory object.
  222. d # NIL    20
  223. dir = d
  224. PROCEDURE Focus (): View
  225. Return focus text view, if one exists.
  226. Except for performace, equivalent to:
  227.     VAR v: Views.View;
  228.     v := Controllers.FocusView();
  229.     IF (v # NIL) & (v IS View) THEN RETURN v(View) ELSE RETURN NIL END
  230. PROCEDURE FocusText (): TextModels.Model
  231. Return focus text, if one exists.
  232. Except for performace, equivalent to:
  233.     VAR v: View;
  234.     v := Focus();
  235.     IF v # NIL THEN RETURN v.ThisModel() ELSE RETURN NIL END
  236. PROCEDURE Deposit
  237. Deposit a default text view in the Views queue.
  238. Except for performace, equivalent to:
  239.     Views.Deposit(dir.StdNew())
  240. PROCEDURE ShowRange (text: TextModels.Model; beg, end: LONGINT;
  241.                                                 focusOnly: BOOLEAN)
  242. For all views v displaying text, issue v.ShowRange(beg, end, focusOnly).
  243. text # NIL    20
  244. Except for performace, equivalent to:
  245.     VAR pm: PositionMsg;
  246.     pm.beg := beg; pm.end := end; pm.focusOnly := focusOnly;
  247.     Models.Broadcast(text, pm)
  248. PROCEDURE ThisRuler (v: View; pos: LONGINT): TextRulers.Ruler
  249. Locate the ruler dominating position pos in the text displayed by v.
  250. v # NIL    20
  251. v.ThisModel() # NIL    21
  252. 0 <= pos    22
  253. pos <= v.ThisModel().Length()    23
  254. Except for performace, equivalent to:
  255.     VAR r: TextRulers.Ruler; a: TextModels.Attributes; rpos: LONGINT;
  256.     v.PollDefaults(r, a); rpos := -1; TextRulers.GetValidRuler(v.ThisModel(), pos, -1, r, rpos);
  257.     RETURN r
  258. TextControllers.StdCtrlDesc
  259. TextControllers.ControllerDesc
  260. Containers.ControllerDesc
  261. Controllers.ControllerDesc
  262. Helvetica
  263. Documents.ControllerDesc
  264.